package com.ego.trade.controller;

import com.ego.commons.pojo.EgoResult;
import com.ego.commons.pojo.OrderPojo;
import com.ego.trade.service.TradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Map;

@Controller
public class TradeController {


    @Autowired
    private TradeService tradeService;

    //下单操作
    @RequestMapping("order/create.html")
    public String orderCreate(OrderPojo orderPojo, Model model){
        System.out.println("orderPojo = " + orderPojo);

        EgoResult result = tradeService.insertOrder(orderPojo);
        if(result.getStatus()!=200){
            model.addAttribute("message",result.getMsg());
            return "error/exception";
        }
        System.out.println("result = " + result);
        model.addAllAttributes((Map)result.getData());
        return "success";
    }

}
